# $ 'Abs Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'ABS() - absolute value
	dim a as single
	dim b as integer

	a = 2.34
	b = abs(a)
	msgbox str$(b)
'end sub

# $ 'AddIni Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AddIni

	'add the contents of myini.ini to win.ini
	a% = AddIni("myini.ini","win.ini")
	if a% then
		msgbox "INI settings added to Win.INI"
	else
		msgbox "AddIni failed."
	end if
'end sub

# $ 'And Operator Exanmple
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'AND statement
	dim a as integer
	dim b as integer

	a = 5
	b = 9
	if (a < 6) AND (b > 8) then
		msgbox "Both conditions were true."
	else
		msgbox "Both conditions were not true."
	end if

	if (a < 6) AND (b > 9) then
		msgbox "Both conditions were true."
	else
		msgbox "Both conditions were not true."
	end if
'end sub

# $ 'AnswerBox Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'AnswerBox example

	'This is a default answer box without 
	'specifying the buttons
	r% = AnswerBox("Example prompt?")
	msgbox str$(r%)	'display the result
	r% = AnswerBox("Example prompt 2?","&Maybe","&Ok","Maybe &Not")
	msgbox str$(r%)	'display the result
'end sub

# $ 'AppActivate Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'AppActivate example

	'activate Applications Manager
	AppActivate "Applications Manager"
'end sub

# $ 'AppClose Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'AppClose example

	'search for a copy of Notepad that is running
	appname$ = AppFind$("Notepad")

	'close the copy of Notepad that was found
	AppClose appname$
'end sub

# $ 'AppFileName$ Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AppFileName$

	'find a copy of Notepad that is running
	appname$ = AppFind$("Notepad")

	'get the name of the program it was executed from
	appfile$ = AppFileName$(appname$)

	'display the file name
	MsgBox appfile$
'end sub

# $ 'AppFind Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AppFind$

	appname$ = AppFind$("Notepad")
	MsgBox appname$
'end sub

# $ 'AppGetActive$ Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AppGetActive$

	'activate a copy of Notepad
	appname$ = AppFind$("Notepad")
	AppActivate appname$

	'now see if it is active
	appname$ = AppGetActive$()
	MsgBox appname$
'end sub

# $ 'AppGetPosition Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AppGetPosition
	dim x, y, w, h as integer

	'Get the position, width and height of Notepad
	appname$ = AppFind$("Notepad")
	AppGetPosition x, y, w, h, appname$

	'display them
	MsgBox appname$+ " is at "+str$(x)+ ","+str$(y)+ " with width of "+str$(w)+ " and height of "+str$(h)
'end sub

# $ 'AppGetState Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AppGetState
	
	appname$ = AppFind$("Notepad")
	appstate% = AppGetState(appname$)
	if appstate% = WS_MAXIMIZED then
		MsgBox appname$ + " is Maximized - " +str$(appstate%)
	else
		if appstate% = WS_MINIMIZED then
			MsgBox appname$ + " is Minimized - " +	str$(appstate%)
		else
			if appstate% = WS_RESTORED then
				MsgBox appname$ + " is Restored - " +	str$(appstate%)
			else
				MsgBox appname$ + " is in an unknown state - " +	str$(appstate%)
			end if
		end if
	end if
'end sub

# $ 'AppHide Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of AppHide and AppShow

	appname$ = AppFind$("Notepad")
	AppHide appname$
	MsgBox appname$+ " is now hidden."
	AppShow appname$
	MsgBox appname$+ " is no longer hidden."
'end sub

# $ 'AppList Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppList
	dim appnames(1) as string

	AppList appnames
	for i% = lbound(appnames) to ubound(appnames)
		MsgBox appnames(i%)
	next i%
'end sub

# $ 'AppMaximize Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppMaximize, AppRestore, and AppMinimize

	appname$ = AppFind$("Notepad")
	AppMaximize appname$
	msgbox appname$+ " is maximized."
	AppRestore appname$
	msgbox appname$+ " is restored."
	AppMinimize appname$
	msgbox appname$+ " is minimized."
'end sub

# $ 'AppMinimize Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppMaximize, AppRestore, and AppMinimize

	appname$ = AppFind$("Notepad")
	AppMaximize appname$
	msgbox appname$+ " is maximized."
	AppRestore appname$
	msgbox appname$+ " is restored."
	AppMinimize appname$
	msgbox appname$+ " is minimized."
'end sub

# $ 'AppMove Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppMove
	dim ax, ay as integer

	'	get current position of Notepad to save
	appname$ = AppFind$("Notepad")
	AppGetPosition ax, ay, 0, 0, appname$

	'	move Notepad around a little
	for i% = 0 to 200
		AppMove i%, i%, appname$
	next i%

	AppMove ax, ay, appname$
'end sub

# $ 'AppRestore Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppMaximize, AppRestore, and AppMinimize

	appname$ = AppFind$("Notepad")
	AppMaximize appname$
	msgbox appname$+ " is maximized."
	AppRestore appname$
	msgbox appname$+ " is restored."
	AppMinimize appname$
	msgbox appname$+ " is minimized."
'end sub

# $ 'AppSetState Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppSetState

	appname$ = AppFind$("Notepad")
	AppSetState WS_MAXIMIZED, appname$
	msgbox "Notepad is maximized"
	AppSetState WS_RESTORED, appname$
	msgbox "Notepad is restored"
	AppSetState WS_MINIMIZED, appname$
	msgbox "Notepad is minimized"
'end sub

# $ 'AppShow Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppHide and AppShow

	appname$ = AppFind$("Notepad")
	AppHide appname$
	MsgBox appname$+ " is now hidden."
	AppShow appname$
	MsgBox appname$+ " is no longer hidden."
'end sub

# $ 'AppSize Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppSize
	dim ax, ay, aw, ah as integer

	appname$ = AppFind$("Notepad")
	AppSetState WS_RESTORED, appname$
	AppGetPosition ax, ay, aw, ah, appname$
	for i% = 10 to 200
		AppSize i%, i%, appname$
	next i%
	AppSize aw, ah, appname$
	AppMove ax, ay, appname$
	AppSetState WS_MINIMIZED, appname$
'end sub

# $ 'AppType Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AppType

	msgbox "After you press OK, you have 10 seconds 		to activate an app to check."
	sleep 10000		'wait for 10 seconds
	appname$ = AppGetActive$()
	at% = AppType(appname$)
	select case at%
		case TYPE_DOS
			msgbox "DOS Application"
		case TYPE_WINDOWS
			msgbox "WINDOWS Application"
	end select
'end sub

# $ 'ArrayDims Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of ArrayDims
	dim apps(1) as string
	dim oapps(1,1) as string

	'ArrayDims shows how many dimensions an array 
	'	was declared with
	msgbox "apps(1) has "+str$(arraydims(apps))+ " dimension(s)."
	msgbox "oapps(1,1) has "+str$(arraydims(oapps))+ 	"dimension(s)."
'end sub

# $ 'ArraySort Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of ArraySort
	dim apps(1) as string

	'get list of running applications
	AppList apps
	'sort it
	ArraySort apps
	'display them
	for i% = lbound(apps) to ubound(apps)
		msgbox apps(i%)
	next i%
'end sub

# $ 'Asc Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of ASC()
	dim acode as integer
	dim astr as string

	astr = "This is a string."
	'the ASC function returns the ASCII code for 
	'the first character of the given string
	acode = asc(astr)
	msgbox "The first character of the string ("+astr+ ") has an ASCII code of "+str$(acode)
'end sub

# $ 'AskBox$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AskBox$

	userinput$ = AskBox$("Key in something below:","This is the default value.")
	msgbox "You entered -> "+userinput$
'end sub

# $ 'AskPassword$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of AskPassword$

	mypassword$ = AskPassword$("Type in a fake password:")
	msgbox "The password you typed was -> "+mypassword$
'end sub

# $ 'Atn Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of ATN (arctangent)
	dim mypi as double

	mypi = 4 * atn(1)
	msgbox str$(mypi)
'end sub

# $ 'Beep Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of BEEP

	beep
'end sub

# $ 'ButtonEnabled Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ButtonEnabled

	appn$ = AppFind$("Notepad")
	if appn$ <> "" then
		AppActivate appn$
		Menu "File.Page Setup"
		if ButtonEnabled("OK") then
			msgbox "OK button is enabled."
		else
			msgbox "OK button is not enabled."
		end if
	end if
'end sub

# $ 'ButtonExists Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ButtonExists

	appn$ = AppFind$("Notepad")
	if appn$ <> "" then
		AppActivate appn$
		Menu "File.Page Setup"
		if ButtonExists("Cancel") then
			msgbox "Cancel button exists."
		else
			msgbox "Cancel button does not exist."
		end if
	end if
'end sub

# $ 'Call Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
sub doubleit (a as integer)
	msgbox str$(a * 2)
end sub

sub main()
	'Example of the Call statement

	'the following statements do the same thing
	Call doubleit (3)
	doubleit(3)
end sub

# $ 'CDbl Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of CDBL
	dim adouble as double
	dim asingle as single
	dim ainteger as integer
	dim along as long

	asingle = pi
	adouble = pi
	ainteger = 30000
	along = 88000
	adouble = cdbl(ainteger)
	msgbox str$(adouble)
	adouble = cdbl(along)
	msgbox str$(adouble)
	msgbox str$(asingle)
	adouble = pi
	msgbox str$(adouble)
	'Now convert the single to double. You'll see a 
	'change in the value due to conversion of a 
	'smaller precision to double precision.
	adouble = cdbl(asingle)
	msgbox str$(adouble)
'end sub

# $ 'ChDir Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of ChDir

	msgbox CurDir$("C")
	ChDir "C:\"
	msgbox CurDir$("C")
'end sub

# $ 'ChDrive Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of ChDrive

	msgbox CurDir$()
	chdrive "D"
	msgbox CurDir$()
'end sub

# $ 'Chr$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of Chr$()

	'List the letters of the alphabet
	startcode = asc("A")
	alphstr$ = ""
	msgbox "The alphabet starts at code "+str$(startcode)
	for i% = startcode to startcode +25
		alphstr$ = alphstr$ +chr$(i%)
	next i%
	msgbox alphstr$
'end sub

# $ 'CInt Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of CINT
	dim a as integer

	a = cint(pi)	'convert PI to an integer
	msgbox str$(a)
'end sub

# $ 'Clipboard$ Statement and Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Clipboard$(), Clipboard$, and 
	'ClipboardClear
	'WARNING: after you run this, your clipboard 
	'contents will be gone

	msgbox Clipboard$()
	ClipboardClear
	msgbox Clipboard$()
	Clipboard$ "I was here!"
	msgbox Clipboard$()
	ClipboardClear
'end sub

# $ 'ClipboardClear Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Clipboard$(), Clipboard$, and 
	'ClipboardClear
	'WARNING: after you run this, your clipboard 
	'contents will be gone

	msgbox Clipboard$()
	ClipboardClear
	msgbox Clipboard$()
	Clipboard$ "I was here!"
	msgbox Clipboard$()
	ClipboardClear
'end sub

# $ 'CLng Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of CLNG
	dim a as long

	a = clng(pi)	'convert PI to a long integer
	msgbox str$(a)
'end sub

# $ 'CSng Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of CSNG()

	dim adouble as double
	dim asingle as single

	adouble =pi
	msgbox str$(adouble)
	asingle = csng(adouble)
	msgbox str$(asingle)
'end sub

# $ 'CStr Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of CSTR

	dim adouble as double
	dim astring as string

	adouble = pi
	astring = cstr(adouble)
	msgbox astring
'end sub

# $ 'CurDir$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of CurDir$()
	dim dstr as string

	dstr = CurDir$()
	msgbox dstr
	dstr = CurDir$("F")   'for a particular drive
	msgbox dstr
'end sub

# $ 'Date$ Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of the Date$ command (not function)
	dim currentdate as string
	dim newdate as string

	currentdate = Date$
	newdate = "1-1-1980"    'This is the earliest 
	                        'date that can be 
	                        'assigned
	Date$ = newdate
	msgbox Date$
	Date$ = currentdate
	msgbox Date$
'end sub

# $ 'Date$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Date$()
	dim dstr as string

	dstr = Date$
	msgbox dstr
	dstr = Date$()
	msgbox dstr
'end sub

# $ 'DateSerial Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of DateSerial
	dim dserial as double

	dserial = DateSerial(1899,12,30) 'Earliest date should be 0
	msgbox str$(dserial)
	dserial = DateSerial(1999,12,30)	'100 years later (note leap years included)
	msgbox str$(dserial)
'end sub

# $ 'DateValue Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DateValue
	dim dval as double

	dval = DateValue(Date$)  'value of current date
	msgbox str$(dval)
'end sub

# $ 'Day Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Day() function (day of month)
	'will show the current date's day of month.
	msgbox str$(Day(DateValue(Date$)))
'end sub

# $ 'DCLHomeDir$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'DCLHomeDir$ example

	a$ = DCLHomeDir$
	msgbox a$
'end sub

# $ 'DCLOS$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DCLOS() function

	a% = DCLOS()
	select case a%
		case 0
			msgbox "Windows"
		case 1
			msgbox "DOS"
	end select
'end sub

# $ 'DCLVersion$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DCLVersion$()

	a$ = DCLVersion$()
	msgbox a$
'end sub

# $ 'Declare Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
declare sub MessageBeep lib "user" (byval n 	as integer)
declare function GetDebugState lib "user" alias "GetSystemDebugState" () as long

'sub main()
	'Example of Declare statement
	'All declared external functions and procedures 
	'exist outside of any DCL function or 
	'subroutines.
	dim debugstate as long

	MessageBeep(-1)    'standard system beep
	debugstate = GetDebugState()
	msgbox str$(debugstate)
'end sub

# $ 'DEFtype Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
DEFInt i - k, x - z
DEFStr s - v
DEFDbl a - c
	
'sub main()
	'example of DEFtype statement
	'This statement is used to define certain 
	'letters of the alphabetic character set to 
	'be used as a certain type of variable.

	i = 1
	msgbox str$(i)
	j = 2.5
	msgbox str$(j)
	s = "test"
	msgbox s
	a = 3
	msgbox str$(a)
	b = 5.6
	msgbox str$(b)
'end sub

# $ 'DesktopCascade Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DesktopCascade
	
	DesktopCascade
'end sub

# $ 'DesktopSetColors Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of DesktopSetColors
	
	msgbox "Click to change to WingTips"
	DesktopSetColors "WingTips"
	msgbox "Click to change to Arizona"
	DesktopSetColors "Arizona"
'end sub

# $ 'DesktopSetWallpaper Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DesktopSetWallpaper

	msgbox "Click to set wallpaper to CASTLE tiled."
	DesktopSetWallpaper "castle.bmp",true
	msgbox "Click to set wallpaper to CASTLE centered."
	DesktopSetWallpaper "castle.bmp",false
	msgbox "Click to clear wallpaper."
	DesktopSetWallpaper "",true
'end sub

# $ 'DesktopTile Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DesktopTile
	
	DesktopTile
'end sub

# $ 'Dialog Statement and Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of using the DIALOG function and command

	'Here is our dialog box specification.
	Begin Dialog UserDialog 16,32,148,72, "Sample"
		OKButton 54,11,41,14
		CancelButton 55,40,41,14
	End Dialog

	'Create a dialog box type variable
	dim mydialog as UserDialog

	'First the function method
	retval% = Dialog(mydialog)
	select case retval%
		case -1
			msgbox "OK pressed."
		case 0
			msgbox "Cancel pressed."
	end select

	'Now the command method
	'First create an error handler in case "Cancel" 
	'is pressed.
	on error goto cancelpressed
	Dialog mydialog
	msgbox "OK pressed."
	goto endprog
cancelpressed:
	msgbox "Cancel pressed."
endprog:
	on error goto 0
'end sub

# $ 'Dim Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of the DIM statement

	'These two statements declare integers
	dim a as integer
	dim b%

	a = 1
	b% = 1

	'These two statements declare strings
	dim s as string
	dim t$

	s = "test"
	t$ = "test"

	'Array declarations
	'When an array is declared, its elements are 
	'numbered 0 through N-1 where N is the size of 
	'the array.  Using the OPTION BASE statement, 
	'you can begin numbering at 1.

	dim j(5) as integer    'array of 5 integer values
	for x% = 0 to 4
		j(x%) = x%
		msgbox str$(j(x%))
	next x%

	dim k(5) as string     'array of 5 strings
	for x% = 0 to 4
		k(x%) = chr$(65+x%)
		msgbox k(x%)
	next x%

	dim l(3,3) as string    'two-dimensional array 
	                        'containing a total of 
	                        '9 strings, 3 by 3
	for x% = 0 to 2
		for y% = 0 to 2
			l(x%,y%) = str$(x%)+str$(y%)
			msgbox l(x%,y%)
		next y%
	next x%

	'Using explicit array subscripts
	dim p(6 to 10) as integer
	for x% = 6 to 10
		p(x%) = x%
		msgbox str$(p(x%))
	next x%
'end sub

# $ 'DirExists Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DirExists

	a$ = "C:\DOS"
	if DirExists(a$) then
		msgbox a$+ " exists"
	else
		msgbox a$+ " does not exist"
	end if
'end sub

# $ 'Dir$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Dir$() function

	a$ = dir$("c:\*.bat")   'initialize file search 
	                 '(filespec parameter required)
	do
		msgbox a$         'display file name
		a$ = dir$()       'next file name 
		                  '(no parameter specified)
	loop while a$ <> ""
'end sub

# $ 'DiskDrives Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DiskDrives command
	dim ddrives() as string

	DiskDrives ddrives
	for i% = lbound(ddrives) to ubound(ddrives)
		alldrives$ = alldrives$ +ddrives(i%)
	next i%
	msgbox alldrives$
'end sub

# $ 'DiskFree Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DiskFree function
	dim ddrives() as string
	dim freespace as long

	DiskDrives ddrives
	for i% = lbound(ddrives) to ubound(ddrives)
		if ddrives(i%) <> "A" and ddrives(i%) <> "B" then
			freespace = DiskFree(ddrives(i%))
			msgbox "Free space on drive "+ddrives(i%)+ ": is "+str$(freespace)
		end if
	next i%
'end sub

# $ 'Do...Loop Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of DO-LOOP statements
	'All of the following loops perform the same task.
	'The difference is primarily in WHEN the loop exit 
	'condition is checked.

	a% = 1
	do while a% = 1
		a% = msgbox("DO-WHILE-LOOP Click cancel to go to next loop.",1)
	loop

	a% = 1
	do until a% <> 1
		a% = msgbox("DO-UNTIL-LOOP Click cancel to go to next loop.",1)
	loop

	a%=1
	do
		a% = msgbox("DO-LOOP-WHILE Click cancel to go to next loop.",1)
	loop while a% = 1

	a% = 1
	do
		a% = msgbox("DO-LOOP-UNTIL Click cancel to go to next loop.",1)
	loop until a% <> 1

	a% = 1
	do
		a% = msgbox("DO-LOOP Click cancel to go to next loop.",1)
		if a% <> 1 then
			exit do
		end if
	loop
'end sub

# $ 'DoEvents Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of DoEvents and DoEvents()

	DoEvents
	x% = DoEvents()
'end sub

# $ 'DoKeys Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of DoKeys
	dim alttab as string

	alttab = "%{TAB}"
	msgbox "Press OK to do first Alt-Tab"
	DoKeys alttab
	msgbox "Press OK to Alt-Tab back to original application"
	DoKeys alttab
'end sub

# $ 'EnableStopScript Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of EnableStopScript

	EnableStopScript ESS_ENABLE
		'control-break enabled
	EnableStopScript ESS_DISABLE
		'control-break disabled
	EnableStopScript ESS_INTERACTIVE
		'control-break only in script editor
'end sub

# $ 'End Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of END

	msgbox "You'll see this one."
	end
	msgbox "You won't see this one."
'end sub

# $ 'Environ$ Function Example     {bmc no_win.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of environ$() function

	a$ = environ$("path")
	msgbox a$
'end sub

# $ 'Err Statement and Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Err(), Error, and Error$()
	dim i as integer

	i=1
nexterror:
	on error goto errortrap
	select case i
		case 1
			error 100
		case 2
			error 101
		case 3
			error 102
	end select
	end

errortrap:
	msgbox "Error #"+str$(err())+ "; "+Error$(err())
	i = i +1
	goto nexterror	
'end sub

# $ 'Error Statement  and Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Err(), Error, and Error$()
	dim i as integer

	i=1
nexterror:
	on error goto errortrap
	select case i
		case 1
			error 100
		case 2
			error 101
		case 3
			error 102
	end select
	end

errortrap:
	msgbox "Error #"+str$(err())+ "; "+Error$(err())
	i = i +1
	goto nexterror	
'end sub

# $ 'Exclusive Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of the Exclusive statement

	Exclusive TRUE    'no multitasking for now
	Exclusive FALSE   'allow other programs to run 
	                  'again
'end sub

# $ 'Exp Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of EXP function

	dim result as double

	result = exp(1)
	msgbox str$(result)
'end sub

# $ 'FileCopy Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FileCopy

	a% = FileCopy("c:\*.bat","c:\batch")
	if a% then
		msgbox "File copy successful."
	else
		msgbox "File copy failed."
	end if
'end sub

# $ 'FileDateTime Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FileDateTime
	dim fdt as double
	dim sfdt as string

	fdt = FileDateTime("C:\AUTOEXEC.BAT")
	sfdt = str$(month(fdt))+ "/"+str$(day(fdt))+	"/"+str$(year(fdt))+ " "+str$(hour(fdt))+ ":"+str$(minute(fdt))+ ":"+str$(second(fdt))
	msgbox sfdt
'end sub

# $ 'FileDirs Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FileDirs statement
	dim fdirs() as string

	'list all directories on drive C:
	FileDirs fdirs,"C:\*.*"

	for i% = lbound(fdirs) to ubound(fdirs)
		fdirlist$ = fdirlist +fdirs(i%) + "; "
	next i%
	msgbox fdirlist$
'end sub

# $ 'FileExists Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FileExists() function

	if FileExists("C:\AUTOEXEC.BAT") then
		msgbox "Autoexec Exists."
	else
		msgbox "Autoexec Does Not Exists."
	end if
	if FileExists("D:\NADA.FIL") then
		msgbox "NADA.FIL Exists."
	else
		msgbox "NADA.FIL Does Not Exist."
	end if
'end sub

# $ 'FileLen Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of the FileLen function
	dim flen as long

	flen = FileLen("C:\AUTOEXEC.BAT")
	msgbox "Autoexec.Bat is"+str$(flen)+ " bytes long."
'end sub

# $ 'FileList Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FileList statement
	dim ffiles() as string
	dim atrib as integer

	atrib = ATTR_NORMAL
	filelist ffiles,"C:\*.*",atrib
	for i% = lbound(ffiles) to ubound(ffiles)
		flist$ = flist$ +ffiles(i%) + "; "
	next i%
	msgbox flist$
'end sub

# $ 'FileParse Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of FileParse$()
	dim filespec as string

	filespec = "C:\DOS\COMMAND.COM"

	'full file specification
	a$ = FileParse$(filespec,0)
	msgbox "Full Filespec = " + a$

	'drive
	a$ = FileParse$(filespec,1)
	msgbox "Drive = " + a$

	'path
	a$ = FileParse$(filespec,2)
	msgbox "Path = " + a$

	'name
	a$ = FileParse$(filespec,3)
	msgbox "Filename = " + a$

	'root
	a$ = FileParse$(filespec,4)
	msgbox "File Rootname = " + a$

	'extension
	a$ = FileParse$(filespec,5)
	msgbox "File Extension = " + a$
'end sub

# $ 'FileType Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
sub DisplayFileType (ftype as integer)
	select case ftype
		case TYPE_DOS
			msgbox "DOS"
		case TYPE_WINDOWS
			msgbox "WINDOWS"
		case else
			msgbox "Unknown Filetype"
	end select
end sub

sub main()
	'example of FileType function

	ftype% = FileType("C:\DOS\COMMAND.COM")
	DisplayFileType(ftype)
	ftype% = FileType("C:\DOS\DOSSHELL.EXE")
	DisplayFileType(ftype)
	ftype% = FileType("D:\WINDOWS\NOTEPAD.EXE")
	DisplayFileType(ftype)
end sub

# $ 'FindFile$ Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FindFile$

	fp$ = FindFile$("notepad.exe")
	if fp$ <> "" then
		msgbox "File found as "+fp$
	else
		msgbox "File not found."
	end if
'end sub

# $ 'Fix Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of the Fix() function
	dim adouble as double
	dim aint as integer

	adouble = pi
	msgbox str$(adouble)
	aint = fix(adouble)
	msgbox str$(aint)
'end sub

# $ 'For...Next Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of FOR-NEXT loops
	dim x as integer    'used as iteration variable 
	                    'for FOR-NEXT
	dim xstart as integer
	dim xend as integer

	'simple form
	for x = 1 to 5
		msgbox str$(x)
	next x

	'step form
	for x = 1 to 10 step 2
		msgbox str$(x)
	next x

	'backward form
	for x = 10 to 1 step -2
		msgbox str$(x)
	next x

	'change of indexes
	for x = 69 to 74
		msgbox chr$(x)
	next x

	'variable range
	xstart = 69
	xend = 74
	for x = xstart to xend
		msgbox "VAR - "+chr$(x)
	next x

	'premature exit
	for x = 1 to 10
		if x = 6 then
			exit for
		end if
		msgbox "Exit - "+str$(x)
	next x
'end sub

# $ 'FreeFile Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of FreeFile%()
	dim nextfile as integer

	nextfile = FreeFile()
	msgbox str$(nextfile)
'end sub

# $ 'GetAttr Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of GetAttr

	i% = GetAttr("C:\IO.SYS")
	msgbox str$(i%)
'end sub

# $ 'GetEnv Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SetEnv and GetEnv$()
	tmp$ = GetEnv$("TMP",ENV_WINDOWS)
	tv$ = AskBox$("New Value For TMP Environment	 Variable:")
	a% = SetEnv("TMP",tv$,ENV_WINDOWS)
	msgbox "New value for TMP is "+	GetEnv$("TMP",ENV_WINDOWS)
	'restore old value
	a% = SetEnv("TMP",tmp$,ENV_WINDOWS)
'end sub

# $ 'GoSub Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of GOSUB and RETURN

	for x% = 1 to 5
		gosub mylabel
	next x%
	end

mylabel:
	msgbox "Here we are!"
	return
'end sub

# $ 'Goto Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of GOTO

	for x% = 1 to 5
		if x% = 3 then goto enditall
	next x%
	msgbox "Error"
	end

enditall:
	msgbox "Ended properly"
	end
'end sub

# $ 'Hex$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Hex$() function

	i% = 31
	h$ = hex$(i%)
	msgbox h$
'end sub

# $ 'HLine Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of HLINE

	ViewPortOpen
	ViewPortClear
	Print "Here is some test data."
	HLine 50
	sleep 2000
	HLine -50
	ViewPortClose
'end sub

# $ 'Hour Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of hour() function
	dim dt as double

	dt = Now
	msgbox str$(hour(dt))	'current hour
'end sub

# $ 'HPage Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of HPage

	ViewPortOpen
	ViewPortClear
	Print "This is some test data"
	HPage 1
	sleep 2000
	HPage -1
	ViewPortClose
'end sub

# $ 'HScroll Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of HSCROLL

	ViewPortOpen
	ViewPortClear
	Print "This is some test data for the viewport scroll test."
	sleep 2000
	HScroll 50	'50 percent scroll
	sleep 2000
	HScroll 0		'no scroll
	sleep 2000
	ViewPortClose
'end sub

# $ 'If...Then...Else Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example IF-THEN-ELSE-END IF statement
	dim a%

	if a% = 1 then
		'do this stuff if a is 1
	elseif a% = 2 then
		'otherwise if a is 2 then do this stuff
	else
		'if a is neither 1 nor 2 then do this stuff
	end if
'end sub

# $ 'InputBox$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of InputBox$() function

	a$ = InputBox$("Enter your description:", 	"Description","",100,200)
	msgbox a$
'end sub

# $ 'InStr Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of InStr() function
	dim teststring as string

	teststring = "The quick brown fox jumps over the lazy dog."
	'search starting at position 1
	i% = InStr(1,teststring,"quick")
	if i% = 0 then
		msgbox "'quick' was not found"
	else
		msgbox "'quick' was found at position"+str$(i%)
	end if
	'search starting at position 10
	i% = InStr(10,teststring,"quick")
	if i% = 0 then
		msgbox "'quick' was not found"
	else
		msgbox "'quick' was found at position"+str$(i%)
	end if
'end sub

# $ 'Int Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of INT function
	dim adouble as double

	adouble = pi
	msgbox str$(adouble)
	msgbox str$(int(adouble))
'end sub

# $ 'Item$ and ItemCount Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Item$() and ItemCount
	dim pathstr as string

	pathstr = environ$("PATH")	'get the path
	msgbox "There are"+str$(itemcount(pathstr,";"))+" items in the path."
	msgbox pathstr
	msgbox item$(pathstr,3,4,";")
'end sub

# $ 'Kill Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of KILL command

	kill "c:\junk.txt"
'end sub

# $ 'LBound Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of LBOUND
	dim ia1(8) as integer
	dim ia2(65 to 70) as integer

	msgbox str$(lbound(ia1))
	msgbox str$(lbound(ia2))
'end sub

# $ 'LCase$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of LCase$
	dim teststr as string

	teststr = "THIS IS A TEST"
	msgbox teststr
	teststr = lcase$(teststr)
	msgbox teststr
'end sub

# $ 'Left$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of left$()
	dim teststr as string

	teststr = "This is a test."
	msgbox teststr
	teststr = left$(teststr,7)
	msgbox teststr
'end sub

# $ 'Len Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Len()
	dim teststr as string

	teststr = "This is a test."
	msgbox "'"+teststr+ "' is"+str$(len(teststr))+" characters long."
'end sub

# $ 'Let Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of Let statement

	let a% = 1
	let s$ = "test"
'end sub

# $ 'Line$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Line$()
	dim crlf as string
	dim testlines as string

	crlf = chr$(13) +chr$(10)
		'carriage return followed by a linefeed
	testlines = "line 1" +crlf
	testlines = testlines + "line 2" +crlf
	testlines = testlines + "line 3" +crlf
	testlines = testlines + "line 4"
	msgbox testlines
	msgbox line$(testlines,2,3)
'end sub

# $ 'LineCount Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of LineCount
	dim crlf as string
	dim testlines as string

	crlf = chr$(13) + chr$(10)
		'carriage return followed by a linefeed
	testlines = "line 1" + crlf
	testlines = testlines + "line 2" +crlf
	testlines = testlines + "line 3" +crlf
	testlines = testlines + "line 4"
	msgbox testlines
	msgbox str$(linecount(testlines))+ " lines total."
'end sub

# $ 'Log Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of log() function

	msgbox "Log of 1 is "+str$(log(1))
	msgbox "Log of 2 is "+str$(log(2))
'end sub

# $ 'LTrim$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of LTrim$()
	dim teststring as string

	teststring = "     testing     "
	msgbox "*" +teststring + "*"
	msgbox "*" +ltrim$(teststring) + "*"
'end sub

# $ 'MCI Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example MCI command
	'NOTE:  This program may not run on your machine.

	dim resultstr as string
	dim errorstr as string

	MCI("play cdrom from 1 to 20",resultstr,errorstr)
'end sub

# $ 'Menu Statement Example    {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Menu command

	aname$ = AppFind$("Notepad")
	AppActivate aname$
	Menu "File.Page Setup"
'end sub

# $ 'Mid$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of mid$() function and command
	dim teststr as string

	teststr = "This is a test."
	msgbox teststr
	msgbox mid$(teststr,3,5)    'starting at 3 and 
	                        'retrieving 5 characters
	mid$(teststr,3,5) = "     "
	msgbox teststr
	msgbox mid$(teststr,3,5)    'starting at 3 and 
	                        'retrieving 5 characters
'end sub

# $ 'Minute Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of minute() function
	dim dt as double

	dt = Now
	msgbox str$(minute(dt))	'current minute
'end sub

# $ 'MkDir Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of mkdir

	MkDir "C:\testdir"
'end sub

# $ 'Mod Operator Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of MOD

	msgbox str$(5 mod 3)    'should display 2--the 
		                   'remainder after division
'end sub

# $ 'Month Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Month

	msgbox str$(month(Now))    'display current month
'end sub

# $ 'MsgBox Statement and Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of MsgBox function and statement

	for i% = 0 to 5
		MsgBox "message", i%, "title"
	next i%
	for i% = 0 to 5
		result = MsgBox("message", i%, "title")
		select case result
			case 1
				msgbox "OK was pressed"
			case 2
				msgbox "Cancel was pressed"
			case 3
				msgbox "Abort was pressed"
			case 4
				msgbox "Retry was pressed"
			case 5
				msgbox "Ignore was pressed"
			case 6
				msgbox "Yes was pressed"
			case 7
				msgbox "No was pressed"
		end select
	next i%

	'In this dialog box the second button is the default.
	result=msgbox("Hello World",3+256,"title")

	'In this dialog box the Stop symbol is displayed.
	result=msgbox("Hello World",3+256+16,"title")

'end sub

# $ 'Name Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Name statement

	Name "C:\JUNK.TXT" as "C:\NEWJUNK.TXT"	
		'renames JUNK.TXT to NEWJUNK.TXT
'end sub

# $ 'NetAttach Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetAttach

	s$ = AskBox$("Server to attach to:")
	u$ = AskBox$("Username:")
	p$ = AskPassword$("Password:")
	if NetAttach(s$,u$,p$) then
		msgbox("Attach Successful.")
	else
		msgbox("Attach Failed.")
	end if
'end sub

# $ 'NetConnectDrive Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetConnectDrive

	lp$ = AskBox$("Local drive to connect to:")
	np$ = AskBox$("Network path to connect:")
	if NetConnectDrive(lp$,np$) then
		msgbox "Drive connected."
	else
		msgbox "Drive connection failed."
	end if
'end sub

# $ 'NetDetach Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetDetach

	s$ = AskBox$("Server To Detach:")
	if NetDetach(s$) then
		msgbox "Server Detached."
	else
		msgbox "Error Detaching Server."
	end if
'end sub

# $ 'NetDirectoryRights Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetDirectoryRights

	p$ = AskBox$("Path to get rights for:")
	r$ = AskBox$("Rights to search for:")
	if NetDirectoryRights(p$,r$) then
		msgbox "You have "+r$+ " rights for "+p$
	else
		msgbox "You do not have "+r$+ " rights for "+p$
	end if
'end sub

# $ 'NetDisconnectDrive Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetDisconnectDrive() function
	dim drive as string
	dim netpath as string

	drive = "k"
	netpath = "sweng_1/sys2:"

	if NetConnectDrive(drive,netpath) then
		msgbox "Drive "+drive+ " has been connected."
		if NetDisconnectDrive(drive) then
			msgbox "Drive "+drive+ " has been disconnected."
		else
			msgbox "Disconnect Failed."
		end if
	else
		msgbox "Connection Failed."
	end if
'end sub

# $ 'NetGetDirectoryRights Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetGetDirectoryRights$()

	p$ = AskBox$("Path to get rights list for:")
	r$ = NetGetDirectoryRights$(p$)
	msgbox "Your rights for "+p$+ " are "+r$
'end sub

# $ 'NetMemberOf Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetMemberOf

	g$ = AskBox$("Group To Search For:")
	s$ = AskBox$("Server To Search:")
	if NetMemberOf(g$,s$) then
		msgbox "You are a member of that group."
	else
		msgbox "You are not a member of that group."
	end if
'end sub

# $ 'NetStationID Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetStationID$()

	nsi$ = NetStationID$()
	msgbox "Your ethernet address is: "+nsi$
'end sub

# $ 'NetUserName Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetUserName

	s$ = AskBox$("Server:")
	nu1$ = NetUserName$()
	nu2$ = NetUserName$(s$)
	msgbox "You are "+nu1$+ " on your primary server, and "+nu2$+ " on "+s$+ "."
'end sub

# $ 'NetworkStatus Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NetworkStatus function

	ns% = NetworkStatus()
	msgbox str$(ns%)
	if ns% AND NS_ACTIVE then
		msgbox "Network is active."
	else
		msgbox "Network is not active."
	end if
	if ns% AND NS_LOGGEDON then
		msgbox "Logged On."
	else
		msgbox "Not Logged On."
	end if
'end sub

# $ 'Not Operator Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of NOT operator
	dim testvar as integer

	testvar = TRUE
	if testvar then
		msgbox "TestVar is TRUE"
	end if

	testvar = FALSE
	if NOT testvar then
		msgbox "TestVar is NOT TRUE"
	end if
'end sub

# $ 'Now Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of the Now function
	dim cdt as double

	cdt = Now
	msgbox "Current date is "+str$(month(cdt))+	"/"+str$(day(cdt))+ "/"+str$(year(cdt))
'end sub

# $ 'Null Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of the Null function
	dim teststr as string

	teststr = "testing"
	msgbox "*"+teststr+ "*"
	teststr = null
	msgbox "*"+teststr+ "*"
'end sub

# $ 'Oct$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Oct$() function

	msgbox Oct$(9)
'end sub

# $ 'On Error Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ON-ERROR statement

	on error goto elabel     'enable error trap
	error 101                'simulate an error
	end

elabel:	                      'error trap label
	on error goto 0     'disable error trapping
	end
'end sub

# $ 'OpenFileName$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of OpenFileName$

	selfile$ = OpenFileName$("Open File",	"All Files:*.bmp, 	*.wmf;Bitmaps:*.bmp;Metafiles:*.wmf")
	msgbox "Selected File = "+selfile$
'end sub

# $ 'Option Base Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
Option Base 1

'sub main()
	'Example of Option Base statement
	dim a(5) as integer

	msgbox str$(lbound(a))
'end sub

# $ 'Or Operator Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'OR statement
	dim a as integer
	dim b as integer

	a = 5
	b = 9
	if (a < 6) OR (b > 8) then
		msgbox "One of the conditions was true."
	else
		msgbox "Neither condition was true."
	end if

	if (a < 6) OR (b > 9) then
		msgbox "One of the conditions was true."
	else
		msgbox "Neither condition was true."
	end if
'end sub

# $ 'PI Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of the PI function
	dim adouble as double

	adouble = pi
	msgbox str$(adouble)
'end sub

# $ 'PopupMenu Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of PopupMenu
	dim apps$() as string
	dim result as integer

	AppList apps$
	result = PopupMenu(apps$)
	if result >= lbound(apps$) then
		msgbox "You chose "+apps$(result)
	else
		msgbox "You chose nothing -"+str$(result)
	end if
'end sub

# $ 'Print Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Print

	ViewPortOpen
	ViewPortClear
	print "this is some data"
	sleep 5000
	ViewPortClose
'end sub

# $ 'Print # Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	open "test.dat" for output as #1
	print #1,10,34,"Hello World";
	a = 10
	s$ = "this is a test"
	print #1,a;s$,
	print #1,67
	close #1
'end sub

# $ 'PrinterGetOrientation Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of PrinterGetOrientation and 
	'PrinterSetOrientation
	dim oldorient as integer

	oldorient = PrinterGetOrientation()
	select case oldorient
		case PO_PORTRAIT
			msgbox "Printer is set up for portrait print."
		case PO_LANDSCAPE
			msgbox "Printer is set up for landscape print."
	end select
	PrinterSetOrientation oldorient
'end sub

# $ 'PrinterSetOrientation Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of PrinterGetOrientation and 
	'PrinterSetOrientation
	dim oldorient as integer

	oldorient = PrinterGetOrientation()
	select case oldorient
		case PO_PORTRAIT
			msgbox "Printer is set up for portrait print."
		case PO_LANDSCAPE
			msgbox "Printer is set up for landscape print."
	end select
	PrinterSetOrientation oldorient
'end sub

# $ 'PrintFile Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of PrintFile

	taskid = printfile("c:\testfile.txt")
	msgbox "Your file is printing as task #"+str$(taskid)
'end sub

# $ 'Random Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Random function

	ViewPortOpen
	ViewPortClear
	for j% = 1 to 10
		i% = Random(1,100)
		print i%
	next j%
	sleep 5000
	ViewPortClose
'end sub

# $ 'Randomize Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Randomize statement

	Randomize 65
	Randomize
'end sub

# $ 'ReadINI$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ReadIni$

	winshell$ = ReadIni$("boot","shell","system.ini")
	msgbox winshell$
'end sub

# $ 'ReadINISection Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ReadIniSection
	dim iniitems() as string

	ReadIniSection "boot",iniitems,"system.ini"
	ViewPortOpen
	print "[Boot] section items from SYSTEM.INI"
	print " "
	for i% = lbound(iniitems) to ubound(iniitems)
		print iniitems(i%)
	next i%
	sleep 5000
	ViewPortClose
'end sub

# $ 'ReDim Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ReDim
	dim stuff(5) as integer

	msgbox str$(ubound(stuff))
	redim stuff(10)
	msgbox str$(ubound(stuff))
'end sub

# $ 'REM Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of REM

REM  this is also a comment
'end sub

# $ 'RefreshIni Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of RefreshIni

	RefreshIni
'end sub

# $ 'Reset Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of RESET statement

	Reset
		'close all open files (writes out i/o buffers)
'end sub

# $ 'RestoreEnv Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SaveEnv and RestoreEnv

	a% = SaveEnv(ENV_WINDOWS)
	a% = RestoreEnv(ENV_WINDOWS)
'end sub

# $ 'Resume Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Resume statement

	on error goto testerror
	error 101
	msgbox "resumed as anticipated"
	on error goto 0
	end

testerror:
	resume next
'end sub

# $ 'Return Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of GOSUB and RETURN

	for x% = 1 to 5
		gosub mylabel
	next x%
	end

mylabel:
	msgbox "Here we are!"
	return
'end sub

# $ 'Right$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of right$()
	dim teststr as string

	teststr = "This is a test."
	msgbox teststr
	teststr = right$(teststr,7)
	msgbox teststr
'end sub

# $ 'RmDir Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of RmDir

	RmDir "C:\testdir"
'end sub

# $ 'Rnd Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Rnd function

	ViewPortOpen
	Randomize
	for i% = 1 to 10
		print Rnd(1)
	next i%
	sleep 5000
	ViewPortClose
'end sub

# $ 'RTrim$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of RTrim$()
	dim teststring as string

	teststring = "     testing     "
	msgbox "*" +teststring + "*"
	msgbox "*" +rtrim$(teststring) + "*"
'end sub

# $ 'SaveEnv Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SaveEnv and RestoreEnv

	a% = SaveEnv(ENV_WINDOWS)
	a% = RestoreEnv(ENV_WINDOWS)
'end sub

# $ 'SaveFileName$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SaveFileName$

	selfile$ = SaveFileName$("Open File","All Files:*.bmp, *.wmf;Bitmaps:*.bmp;Metafiles:*.wmf")
	msgbox "Selected File = "+selfile$
'end sub

# $ 'Second Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of second() function
	dim dt as double

	dt = Now
	msgbox str$(second(dt))....'current second
'end sub

# $ 'Select...Case Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SELECT-CASE statement

	i% = 1
	select case i%
		case 1
			msgbox "i% is 1"
		case 2
			msgbox "i% is 2"
	end select
'end sub

# $ 'SelectBox Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of SelectBox function
	dim alist() as string

	AppList alist
	result% = SelectBox("Application List","Pick One",alist)
	msgbox "You selected "+alist(result%)
'end sub

# $ 'SendKeys Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SendKeys
	dim alttab as string

	alttab = "%{TAB}"
	msgbox "Press OK to do first Alt-Tab"
	SendKeys alttab,TRUE
	msgbox "Press OK to Alt-Tab back to original application"
	SendKeys alttab,FALSE
'end sub

# $ 'SetAttr Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SetAttr

	SetAttr "C:\AUTOEXEC.BAT",0
		'set file attribute to NORMAL
'end sub

# $ 'SetEnv Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SetEnv and GetEnv$()
	tmp$ = GetEnv$("TMP",ENV_WINDOWS)
	tv$ = AskBox$("New Value For TMP Environment Variable:")
	a% = SetEnv("TMP",tv$,ENV_WINDOWS)
	msgbox "New value for TMP is "+	GetEnv$("TMP",ENV_WINDOWS)
	'restore old value
	a% = SetEnv("TMP",tmp$,ENV_WINDOWS)
'end sub

# $ 'Sgn Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SGN() function

	i% = -2
	msgbox str$(sgn(i%))
	i% = 0
	msgbox str$(sgn(i%))
	i% = 2
	msgbox str$(sgn(i%))
'end sub

# $ 'Shell Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Shell function

	taskid% = Shell("notepad.exe",1)
'end sub

# $ 'Sin Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Sin() function
	
	result# = sin(0)
	msgbox str$(result#)
	result# = sin(1)
	msgbox str$(result#)
'end sub

# $ 'Sleep Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Sleep command

	msgbox "Press OK to sleep 5 seconds"
	sleep 5000
'end sub

# $ 'SleepUntil Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SleepUntil

	t$ = time$()		'get current time
	t$ = left$(t$,5)	'get hours and 
						'minutes only
	m$ = right$(t$,2)	'get minutes value
	h$ = left$(t$,2)		'get hour value
	x = val(m$)		'get the value of the minutes
	y = val(h$)		'get value of hour string
	x = x + 2			'increment minutes 
						'to wait 2 minutes
	if x > 59 then
		y = y + 1
		x = x - 59
	end if
	h$ = str$(y)		'convert hours 
						'back to string
	h$ = right$(h$,len(h$)-1)
		'get rid of leading blank from conversion
	if len(h$) = 1 then h$ = "0" + h$
	m$ = str$(x)		'convert minutes 
					        'back to string likewise
	m$ = right$(m$,len(m$)-1)
	if len(m$) = 1 then m$ = "0" + m$
	t$ = h$+ ":"+m$		'reconstruct time 
						'value
	retval% = SleepUntil(t$,TRUE,	"Press CANCEL to quit.","Sleeping Until "+t$,TRUE,TRUE)
'end sub

# $ 'Snapshot Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SnapShot statement

	SnapShot 4	'active window
	taskid% = Shell("pbrush.exe")
	DoKeys "+{INSERT}"	'paste clipboard 
	                            'into paintbrush
'end sub

# $ 'Space$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Space$() function

	stuff$ = null
	msgbox "*"+stuff$+ "*"
	stuff$ = space$(10)
	msgbox "*"+stuff$+ "*"
'end sub

# $ 'Sqr Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SQR function

	msgbox str$(sqr(100))
'end sub

# $ 'Stop Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Stop statement

	Stop
'end sub

# $ 'StrComp Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of StrComp function

	'Case-sensitive comparison
	teststr$ = "This is a test string"
	result% = StrComp(teststr$,"THIS IS A TEST STRING",0)
	
	select case result%
		case -1
			msgbox "teststr$ is less than the compare string"
		case 0
			msgbox "teststr$ is equal to the compare string"
		case 1
			msgbox "teststr$ is greater than compare string"
	end select

	'Case-insensitive comparison
	result% = StrComp(teststr$,"THIS IS A TEST STRING",1)
	select case result%
		case -1
			msgbox "teststr$ is less than the compare string"
		case 0
			msgbox "teststr$ is equal to the compare string"
		case 1
			msgbox "teststr$ is greater than compare string"
	end select
'end sub

# $ 'Str$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of str$() function

	i% = 3
	s$ = str$(i%)
	msgbox s$
'end sub

# $ 'String$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of String$() function

	s$ = String$(10,65)
	msgbox s$
	s$ = String$(10,"B")
	msgbox s$
'end sub

# $ 'SystemFreeMemory Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SystemFreeMemory

	msgbox "Free Memory ="+str$(SystemFreeMemory)
'end sub

# $ 'SystemFreeResources Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SystemFreeResources

	msgbox "Free Resources =" +str$(SystemFreeResources)+ "%"
'end sub

# $ 'SystemMouseTrails Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SystemMouseTrails

	SystemMouseTrails TRUE
	msgbox "Move the Mouse Around Now"
	SystemMouseTrails FALSE
'end sub

# $ 'SystemRestart Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SystemRestart
	'WARNING:	this will restart Windows if you run it

	SystemRestart
'end sub

# $ 'SystemTotalMemory Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'example of SystemTotalMemory

	msgbox "Total System Memory ="+str$(SystemTotalMemory)
'end sub

# $ 'SystemWindowsDirectory$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SystemWindowsDirectory$

	msgbox SystemWindowsDirectory$
'end sub

# $ 'SystemWindowsVersion$ Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of SystemWindowsVersion$

	msgbox SystemWindowsVersion$
'end sub

# $ 'Tan Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Tan() function

	i# = Tan(1)
	msgbox str$(i#)
'end sub

# $ 'Time$ Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Time command
	
	time$ = "21:30:40"
'end sub

# $ 'Time$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Time$() function

	msgbox Time$()
'end sub

# $ 'Timer Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Timer function
	dim tval as long

	tval = Timer
	msgbox str$(tval)
'end sub

# $ 'TimeSerial Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of TimeSerial function
	dim tser as double

	tser = TimeSerial(21,40,44)
'end sub

# $ 'TimeValue Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of TimeValue function
	dim tval as double

	tval = TimeValue("21:40:44")
'end sub

# $ 'Trim$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Trim$()
	dim teststring as string

	teststring = "     testing     "
	msgbox "*" +teststring + "*"
	msgbox "*" +trim$(teststring) + "*"
'end sub

# $ 'UBound Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of UBOUND
	dim ia1(8) as integer
	dim ia2(65 to 70) as integer

	msgbox str$(ubound(ia1))
	msgbox str$(ubound(ia2))
'end sub

# $ 'UCase$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of UCase$
	dim teststr as string

	teststr = "this is a test"
	msgbox teststr
	teststr = ucase$(teststr)
	msgbox teststr
'end sub

# $ 'Val Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Val function

	teststr$ = "123.3"
	tval# = val(teststr$)
	msgbox str$(tval)
'end sub

# $ 'Viewport Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of ViewPort commands

	'Create a veiwport window
	ViewPortOpen "My ViewPort"
	For i% = 1 to 20
		Print i%
	Next i%
	msgbox "Press OK to clear the viewport."
	ViewPortClear
	msgbox "Press OK to close the viewport."
	ViewPortClose
'end sub

# $ 'VLine Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of VLINE

	ViewPortOpen
	ViewPortClear
	for i% = 1 to 50
		Print "Here is some test data."
	next i%
	VLine 50
	sleep 2000
	VLine -50
	ViewPortClose
'end sub

# $ 'VPage Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Examples of VPage

	ViewPortOpen
	ViewPortClear
	for i% = 1 to 50
		Print i%
	next i%
	VPage 1
	sleep 2000
	VPage -1
	ViewPortClose
'end sub

# $ 'VScroll Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of VSCROLL

	ViewPortOpen
	ViewPortClear
	for i% = 1 to 50
		Print "Test data for viewport scroll test."
	next i%
	sleep 2000
	VScroll 50	'50 percent scroll
	sleep 2000
	VScroll 1		'no scroll
	sleep 2000
	ViewPortClose
'end sub

# $ 'WaitForTaskCompletion Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WaitForTaskCompletion

	taskid% = Shell("notepad",1)
	'The next statement pauses until Notepad 
	'is shut down
	WaitForTaskCompletion taskid%
	msgbox "All done."
'end sub

# $ 'Weekday Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Weekday()

	wday% = weekday(Now)
	select case wday%
		case 1
			msgbox "Today Is Sunday"
		case 2
			msgbox "Today Is Monday"
		case 3
			msgbox "Today Is Tuesday"
		case 4
			msgbox "Today Is Wednesday"
		case 5
			msgbox "Today Is Thursday"
		case 6
			msgbox "Today Is Friday"
		case 7
			msgbox "Today Is Saturday"
	end select
'end sub

# $ 'While...Wend Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WHILE-WEND

	i% = 4
	while i% > 1
		msgbox "not yet"
		i% = i% -1
	wend
	msgbox str$(i%)
'end sub

# $ 'WinActivate Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinActivate

	appn$ = AppFind$("Notepad")
	WinActivate appn$
'end sub

# $ 'WinClose Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinClose

	appn$ = AppFind$("Notepad")
	WinClose appn$
'end sub

# $ 'WinFind Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinFind

	appn$ = AppFind$("Notepad")
	hWnd% = WinFind(appn$)
	msgbox str$(hWnd%)
'end sub

# $ 'WinList Function Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinList
	dim hWindows() as integer

	WinList hWindows
	for i% = lbound(hWindows) to ubound(hWindows)
		msgbox str$(hWindows(i%))
	next i%
'end sub

# $ 'WinMaximize Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinMaximize

	appn$ = AppFind$("Notepad")
	WinMaximize appn$
'end sub

# $ 'WinMinimize Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinMinimize

	appn$ = AppFind$("Notepad")
	WinMinimize appn$
'end sub

# $ 'WinMove Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinMove

	appn$ = AppFind$("Notepad")
	for i% = 0 to 100
		WinMove i%, i%, appn$
	next i%
'end sub

# $ 'WinRestore Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinRestore

	appn$ = AppFind$("Notepad")
	WinRestore appn$
'end sub

# $ 'WinSize Statement Example     {bmc no_dos.bmp}
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WinSize

	appn$ = AppFind$("Notepad")
	for i% = 1 to 200
		WinSize i%, i%, appn$
	next i%
'end sub

# $ 'Word$ Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WORD$() and WORDCOUNT functions
	dim teststr as string

	teststr = "The quick brown fox jumps over the lazy dog."
	for i% = 1 to wordcount(teststr)
		msgbox word$(teststr,i%,i%)
	next i%
'end sub

# $ 'WordCount Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WORD$() and WORDCOUNT functions
	dim teststr as string

	teststr = "The quick brown fox jumps over the lazy dog."
	for i% = 1 to wordcount(teststr)
		msgbox word$(teststr,i%,i%)
	next i%
'end sub

# $ 'WriteINI Statement Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of WriteIni statement

	WriteIni "anewsection","anewitem","value","win.ini"
'end sub

# $ 'Xor Operator Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of XOR
	dim a as integer
	dim b as integer

	a = 5
	b = 9
	if (a < 6) XOR (b > 8) then
		msgbox "Both conditions were not the same."
	else
		msgbox "Both conditions were the same--either TRUE or FALSE."
	end if

	if (a < 6) XOR (b > 9) then
		msgbox "Both conditions were not the same."
	else
		msgbox "Both conditions were the same--either TRUE or FALSE."
	end if
'end sub

# $ 'Year Function Example
{bmc xc_copy2.bmp}    {bmc xc_copy.bmp}   {bmc xc_print.bmp}   {bmc xc_close.bmp}
'sub main()
	'Example of Year

	msgbox str$(year(Now))    'display current year
'end sub